<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="ClientTemplate.xhtml">   
        <ui:define name="body"> 
            <h:form>
                <p:tabView id="tabView" orientation="top">  

                    <p:tab id="tab1" title="New Feedback"> 
                        <h:panelGrid columns="3" cellpadding="10" >

                            <h:outputLabel value="ClientName" for="fbClientName" />
                            <p:inputText id="fbClientName" value="#{feedbackController.selected.fbClientName}" title="Name" />
                            <h:panelGroup/>

                            <h:outputLabel value="Description :" for="fbDescription" /> 
                            <h:inputTextarea id="fbDescription" value="#{feedbackController.selected.fbDescription}" title="Description" />
                            <h:panelGroup/>

                            <h:outputLabel value="SatisfyingLevel :" for="fbSatisfyingLevel" />
                            <p:selectOneRadio id="fbSatisfyingLevel" value="#{feedbackController.selected.fbSatisfyingLevel}" >  
                                <f:selectItem itemLabel="Good" itemValue="1" />  
                                <f:selectItem itemLabel="Medium" itemValue="2" /> 
                                <f:selectItem itemLabel="Poorly" itemValue="3" />  
                            </p:selectOneRadio>
                            <h:panelGroup/>

                            <h:outputLabel value=" Problem :" for="fbProblem" /> 
                            <h:inputTextarea id="fbProblem" value="#{feedbackController.selected.fbProblem}" title="Problem" />
                            <h:panelGroup/>

                            <h:panelGroup/>
                            <h:inputHidden id="fbImprovement" value="#{feedbackController.selected.fbImprovement}" />
                            <h:panelGroup/>
                            <f:facet name="footer">
                                <p:commandButton action="#{feedbackController.create}" value="Save" icon="ui-icon-check"/>
                            </f:facet>
                        </h:panelGrid>


                    </p:tab>
                    <p:tab id="tab2" title="Feedback History"> 
                        <p:growl id="messages" showDetail="true"/> 
                        <h:outputText escape="false" value="You are not the login"  rendered="#{empty loginController.userLogin}"/>
                        <h:outputText escape="false" value="Not Feedback" rendered="#{feedbackController.items.rowCount == 0}"/>
                        <h:panelGroup rendered="#{feedbackController.items.rowCount > 0}">
                            <p:dataTable id="dataTable" var="item" value="#{feedbackController.listUserFeedback(loginController.userLogin.usID)}"
                                         paginator="true" rows="10" paginatorPosition="bottom" resizableColumns="true"
                                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                         rowsPerPageTemplate="5,10,15" style="width: 100%" widgetVar="roomTable" >                               >
                                <f:facet name="header">
                                    <h:outputText value="List of Feedback"/>
                                    
                                </f:facet>
                                <p:column headerText="ID" sortBy="#{item.fbID}" >
                                    <h:outputText value="#{item.fbID}" style="width: 100%"/>               
                                </p:column>

                                <p:column headerText="ClientName" sortBy="#{item.fbClientName}" >
                                    <h:outputText value="#{item.fbClientName}"/>               
                                </p:column>   

                                <p:column headerText="User" sortBy="#{item.usID.usName}" filterMatchMode="exact" filterBy="#{item.usID.usName}">
                                    <h:outputText value="#{item.usID.usName}"/>                
                                </p:column>
                                <p:column headerText="Description" sortBy="#{item.fbDescription}">
                                    <h:outputText value="#{item.fbDescription}"/>                   
                                </p:column>
                                <p:column headerText="SatisfyingLevel" sortBy="#{item.fbSatisfyingLevel}" filterMatchMode="exact" filterBy="#{item.fbSatisfyingLevel}" >
                                    <h:outputText value="Good" rendered="#{item.fbSatisfyingLevel == 0}"/>
                                    <h:outputText value="Medium" rendered="#{item.fbSatisfyingLevel == 1}"/>
                                    <h:outputText value="Poorly" rendered="#{item.fbSatisfyingLevel == 2}"/>                  
                                </p:column>
                                <p:column headerText="Problem" sortBy="#{item.fbProblem}">
                                    <h:outputText value="#{item.fbProblem}"/>                  
                                </p:column>
                                <p:column headerText="Improvement" sortBy="#{item.fbImprovement}">
                                    <h:outputText value="#{item.fbImprovement}"/>                 
                                </p:column>

                                <p:column headerText="Status" sortBy="#{item.fbStatus}" filterMatchMode="exact" filterBy="#{item.fbStatus}">
                                    <h:outputText value="#{item.fbStatus}"/>                 
                                </p:column>   
                                <p:column headerText="Manager" sortBy="#{item.mnID.mnName}"  filterMatchMode="exact" filterBy="#{item.mnID.mnName}" >
                                     <h:outputText value="#{item.mnID.mnName}"/>                  
                                </p:column>
                                <p:column>
                                    <p:rowEditor/>
                                </p:column>
                            </p:dataTable>
                        </h:panelGroup>
                    </p:tab>
                </p:tabView>
            </h:form>
        </ui:define>
    </ui:composition>
</html>

